package com.iqiao.platform.controller.admin;

import com.github.pagehelper.PageInfo;
import com.iqiao.common.web.Servlets;
import com.iqiao.common.web.result.JsonResult;
import com.iqiao.common.web.result.PageResult;
import com.iqiao.platform.model.Role;
import com.iqiao.platform.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping(value = "roles")
public class RoleController {

    @Autowired
    private RoleService roleService;

    /**
     *  查询角色列表
     * @param request
     * @param response
     * @return
     */
    @GetMapping()
    public JsonResult findList(
            HttpServletRequest request,
            HttpServletResponse response) {
        Map<String, Object> params = Servlets.getParams(request);
        PageInfo<Role> pageInfo = roleService.findPage(params);
        return PageResult.success(pageInfo);
    }
}
